<template>
  <div class="app-container">
        <!--仓库-->
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
           <!-- <el-form-item prop="deptId">
              <treeselect v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="部门"
                style="width: 480px" />
            </el-form-item> -->
            <el-form-item prop="storeId">
              <!-- <treeselect v-model="queryParams.storeId" :options="storeOptions" :show-count="true" placeholder="请选择仓库"
                style="width: 480px" size="mini"/> -->
                <el-select v-model="queryParams.storeId" placeholder="仓库" clearable size="small">
                    <el-option v-for="dict in storeOptions" :key="dict.id" :label="dict.label"
                      :value="dict.id" />
                  </el-select>
            </el-form-item>

            <!-- <el-form-item prop="exno">
              <el-input v-model="queryParams.exno" placeholder="出库单号" clearable
                @keyup.enter.native="handleQuery" />
            </el-form-item> -->

            <el-form-item prop="viewingNo">
              <el-input v-model="queryParams.viewingNo" placeholder="看样编号" clearable
                @keyup.enter.native="handleQuery" size="small"/>
            </el-form-item>
            <!-- <el-form-item prop="status">
              <el-select v-model="queryParams.status" placeholder="状态" clearable>
                <el-option v-for="dict in dict.type.wms_pick_task_status" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item> -->

            <el-form-item>
              <el-date-picker v-model="daterangeFinishTime"  style="width: 240px" value-format="yyyy-MM-dd" size="small"
                type="daterange" range-separator="-" start-placeholder="起始日期" end-placeholder="截止日期"></el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>

        <!-- <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
              v-hasPermi="['wms:viewing:add']">新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
              v-hasPermi="['wms:viewing:edit']">修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
              v-hasPermi="['wms:viewing:remove']">删除</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
              v-hasPermi="['wms:viewing:export']">导出</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row> -->

        <el-table v-loading="loading" :data="viewingList" @selection-change="handleSelectionChange" border stripe>
          <el-table-column type="selection" width="55" align="center" fixed="left"/>
          <!-- <el-table-column label="记录ID" align="center" prop="id" v-if="true" /> -->
          <el-table-column label="看样编号" align="left" prop="viewingNo"  width="120" fixed="left">
            <template slot-scope="scope">
              <el-link type="primary" @click="handleInfo(scope.row)">{{scope.row.viewingNo}}</el-link>
            </template>
          </el-table-column>
          <el-table-column label="申请单位" align="left" prop="deptName" width="180" fixed="left"/>
          <el-table-column label="仓库" align="center" prop="storeName" width="80"/>
          <el-table-column label="联系人" align="left" prop="name" width="260"/>
          <el-table-column label="联系电话" align="left" prop="tel" width="120" />
          <el-table-column label="证件号码" align="left" prop="idCard" width="180" />
          <el-table-column label="看样时间" align="center" prop="applyDay" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.applyDay) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="看样方式" align="center" prop="type" width="100">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.viewType == '0'" type="primary">现场阅证</el-tag>
              <el-tag v-if="scope.row.viewType == '1'" type="warning">拍卖看样</el-tag>
              <el-tag v-if="scope.row.viewType == '2'" type="warning">评估鉴定</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="审核状态" align="center" prop="checkStatus" width="160">
             <template slot-scope="scope">
               <dict-tag :options="dict.type.sys_check_status" :value="scope.row.checkStatus" />
             </template>
           </el-table-column>
          <el-table-column label="状态" align="center" prop="status">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.wms_view_status" :value="scope.row.status" />
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
            <!-- <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleInfo(scope.row)"
                v-hasPermi="['wms:viewing:query']" >查看</el-button>
             <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                v-hasPermi="['wms:viewing:remove']">删除</el-button>
            </template> -->
            <template slot-scope="scope">
              <el-button type="text"  icon="el-icon-s-check" size="mini" v-if="scope.row.checkStatus == '0'"  @click="handleCheck(scope.row)"
                v-hasPermi="['oms:task:edit']">审核</el-button>
             <!-- <el-tag v-if="scope.row.checkStatus == '1'" type="success">已审核</el-tag>
              <el-tag v-if="scope.row.checkStatus == '2'" type="info">已审核</el-tag> -->
              <el-button size="mini" v-if="scope.row.checkStatus == '1' || scope.row.checkStatus == '2'" type="text" icon="el-icon-view" @click="handleInfo(scope.row)"
                v-hasPermi="['oms:task:edit']">查看</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
          @pagination="getList" />
      </el-col>
    </el-row>

    <!-- 添加或修改看样记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="880px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">

        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="看样编号" prop="viewingNo">
              <el-input v-model="form.viewingNo" placeholder="请输入看样编号" disabled />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="申请部门" prop="deptId">
              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="部门"
                style="width: 160px" size="small" />
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="申请人" prop="operator">
              <el-select v-model="form.operator" placeholder="请选择申请人" filterable allow-create>
                <el-option v-for="item in contactsOptions" :key="item.userId" :label="item.nickName"
                  :value="item.userId" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="申请日期" prop="applyDay">
              <el-date-picker clearable size="small" v-model="form.applyDay" type="date"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择申请日期" style="width: 160px;">
              </el-date-picker>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="仓库" prop="storeId">
             <treeselect v-model="form.storeId" :options="storeOptions" :show-count="true" placeholder="请选择仓库" />
            </el-form-item>
          </el-col>


          <!-- <el-col :span="8">
            <el-form-item label="状态" prop="status">
              <el-select v-model="form.status" placeholder="请选择状态">
                <el-option v-for="dict in dict.type.wms_view_status" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
        </el-row>

        <el-row :gutter="15">
          <el-col>
            <el-form-item label="备注" prop="memo">
              <el-input v-model="form.memo" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="15">
          <el-col>
            <el-form-item label="图片附件" prop="pics">
              <image-upload v-model="form.pics" ref="imageUpload" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :offset="2" :span="22">
            <el-card shadow="hover">
              <div slot="header" class="clearfix">
                <span>看样清单</span>
                <el-button type="text" style="float:right;padding: 3px 0" @click="addDtl">新增</el-button>
              </div>
              <el-table :data="form.items" border stripe>
                <el-table-column label="物品编号" align="center" prop="pno">
                  <template slot-scope="scope">
                   <el-input placeholder="请输入物品编号" v-model="scope.row.pno" />
                  </template>
                </el-table-column>
                <el-table-column label="物品名称" align="center" prop="name">
                  <template slot-scope="scope">
                    <el-input placeholder="请输入物品名称" v-model="scope.row.name" />
                  </template>
                </el-table-column>
                <el-table-column label="数量" align="center" prop="nums">
                  <template slot-scope="scope">
                    <el-input placeholder="请输入物品数量" v-model="scope.row.nums" />
                  </template>
                </el-table-column>
                <el-table-column label="操作" align="left">
                  <template slot-scope="scope">
                    <el-row>
                      <el-col>
                        <el-button type="danger" size="mini" @click="dtlDel(scope)" v-if="scope.row.delFlag == '0'">删除</el-button>
                        <el-tag type="info" v-if="scope.row.delFlag == '2'">已删除</el-tag>
                      </el-col>
                    </el-row>
                  </template>
                </el-table-column>
              </el-table>
            </el-card>
          </el-col>
        </el-row>
      </el-form>
      <selectProperty  ref="elDrawer" @handleSelected="handleSelected"></selectProperty>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-drawer :title="title" :visible.sync="drawerOpen" size="80%"  :before-close="handleClose">
      <div class="mainDiv" style="padding-top: 60px;">
        <el-container class="main_container">
          <el-main>
            <el-tabs v-model="activeName">
              <el-tab-pane label="基本信息" name="0">
                <el-card class="box-card" v-if="store.name && store.name != ''">
                    <div slot="header" class="clearfix">
                      <span>仓库信息</span>
                    </div>
                    <el-descriptions class="margin-top" :column="2" border>
                        <el-descriptions-item label="仓库">{{store.name}}</el-descriptions-item>
                        <el-descriptions-item label="联系人">{{store.nickName}}</el-descriptions-item>
                        <el-descriptions-item label="联系电话">{{store.phonenumber}}</el-descriptions-item>
                        <el-descriptions-item label="中心电话">{{store.tel}}</el-descriptions-item>
                      </el-descriptions>
                 </el-card>
                 <el-card class="box-card mt10">
                   <div slot="header" class="clearfix">
                     <span>基本信息</span>
                   </div>
                    <el-descriptions class="margin-top" :column="4" border>
                      <el-descriptions-item label="看样编号">{{form.viewingNo}}</el-descriptions-item>
                      <el-descriptions-item label="仓库">{{form.storeName}}</el-descriptions-item>
                      <el-descriptions-item label="申请时间">
                        {{ parseTime(form.applyDay) }}
                      </el-descriptions-item>
                      <el-descriptions-item label="状态">
                        <dict-tag :options="dict.type.wms_view_status" :value="form.status" />
                      </el-descriptions-item>
                      <el-descriptions-item label="审核状态">
                        <dict-tag :options="dict.type.sys_check_status" :value="form.checkStatus" />
                      </el-descriptions-item>
                      <el-descriptions-item label="审核不通过理由" v-if="form.checkStatus == '2'">
                        {{form.memo}}
                      </el-descriptions-item>
                      <el-descriptions-item label="备注" v-if="form.type == '1'">
                        {{form.memo}}
                      </el-descriptions-item>
                    </el-descriptions>
                    <el-descriptions class="margin-top" v-for="(item, index) in form.personData" :column="4" border>
                        <el-descriptions-item label="联系人">{{item.name}}</el-descriptions-item>
                        <el-descriptions-item label="联系电话">{{item.tel}}</el-descriptions-item>
                        <el-descriptions-item label="证件类型" v-if="form.type=='0'">{{item.cardType=='0'?'身份证':'警官证'}}</el-descriptions-item>
                        <el-descriptions-item label="证件号码" v-if="form.type=='0'">{{item.idCard}}</el-descriptions-item>
                      </el-descriptions>
                 </el-card>
                 <el-row :gutter="10" v-if="form.watchType == '1'">
                   <el-col :span="12">
                     <el-card class="box-card mt10">
                       <div slot="header" class="clearfix">
                         <span>现场图片</span>
                          <!-- <el-button type="primary" plain size="mini" class="fr" icon="el-icon-upload">上传</el-button> -->
                       </div>
                        <image-upload v-model="form.sceneOss" :params="{'buss':'scenePicture',objid:form.id}"></image-upload>
                     </el-card>
                   </el-col>
                   <el-col :span="12">
                      <el-card class="box-card mt10">
                        <div slot="header" class="clearfix">
                          <span>现场视频</span>
                           <!-- <el-button type="primary" plain size="mini" class="fr" icon="el-icon-upload">上传</el-button> -->
                        </div>
                         <fileUpload v-model="form.sceneVideo" :params="{'buss':'scenePicture',objid:form.id}" :fileType="['mp4','MP4']" :fileSize="20"/>
                      </el-card>
                   </el-col>
                 </el-row>

                 <el-card class="box-card mt10">
                   <div slot="header" class="clearfix">
                     <span>附件信息</span>
                   </div>
                    <el-descriptions class="margin-top" :column="2" border>
                        <el-descriptions-item label="证件照">
                          <el-image v-if="form.oss && form.oss.length > 0" v-for="(pic,pindex) in form.oss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(form.oss,'list')"></el-image>
                        </el-descriptions-item>
                        <el-descriptions-item label="物品附件">
                          <el-image v-if="form.itemsOss && form.itemsOss.length > 0" v-for="(pic,pindex) in form.itemsOss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(form.itemsOss,'list')"></el-image>
                        </el-descriptions-item>
                        <el-descriptions-item label="中心受理人签名">
                          <el-image style="width: 120px; height: 60px;margin-right: 5px;" :src="getPictureHost()+form.centerSign"/>
                        </el-descriptions-item>
                       <el-descriptions-item label="阅证人签名">
                         <el-image style="width: 120px; height: 60px;margin-right: 5px;" :src="getPictureHost()+form.signs"/>
                       </el-descriptions-item>
                      </el-descriptions>
                 </el-card>
              </el-tab-pane>
              <el-tab-pane label="物品清单" name="1">
                <el-card class="box-card mt10">
                  <div slot="header" class="clearfix">
                    <span>物品清单</span>
                  </div>
                  <el-table :data="form.items" border stripe>
                    <el-table-column type="index" width="55" align="center"></el-table-column>
                    <el-table-column label="物品编号" align="left" prop="pno" width="260">
                      <template slot-scope="scope">
                        <span>{{scope.row.pno}}</span>
                      </template>
                    </el-table-column>
                    <el-table-column label="物品名称" align="left" prop="name" width="200">
                      <template slot-scope="scope">
                        <span>{{scope.row.name}}</span>
                      </template>
                    </el-table-column>
                    <el-table-column label="数量" align="center" prop="nums" width="75">
                      <template slot-scope="scope">
                        <span>{{scope.row.nums}}</span>
                      </template>
                    </el-table-column>
                    <el-table-column label="图片" align="left" prop="oss">
                      <template slot-scope="scope">
                        <el-image v-if="scope.row.oss && scope.row.oss.length > 0" v-for="(pic,pindex) in scope.row.oss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(scope.row.oss,'list')"></el-image>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-card>
              </el-tab-pane>
              <el-tab-pane label="阅证单" name="2">
                <el-card class="mb10 mt10" shadow="hover">
                  <div slot="header" class="clearfix" >
                    <el-button type="warning" icon="el-icon-printer"   size="mini" class="fr ml10" @click="handlePrint(taskNoTitle+form.taskNo)">下载打印</el-button>
                    <el-button type="primary" icon="el-icon-view"   size="mini" class="fr" @click="handlePrintInfo()">在线查看</el-button>
                  </div>
                   <div  ref="printHandover" id="printHandover">
                     <el-card id="handoverCard" class="box-card" style="padding: 50px 2vw 30px 2vw;background-color:#fff;" shadow="never">
                       <div slot="header" style="text-align: center;font-size:18px;margin-bottom: 20px;font-weight: 800;padding-bottom: 15px;">
                           <span>涉案财物现场阅证单</span>
                       </div>
                       <el-descriptions :column="3" class="mb10 mt10" :labelStyle="{'backgroundColor':'#fff','fontSize':'16px','fontWeight':'bold'}" :contentStyle="{'fontSize':'16px','fontWeight':'bold'}">
                         <el-descriptions-item label="阅证编号">{{form.viewingNo}}</el-descriptions-item>
                         <el-descriptions-item label="保管员">{{form.storeUser}}</el-descriptions-item>
                         <el-descriptions-item label="阅证时间">{{parseTime(form.applyDay) }}</el-descriptions-item>
                         <el-descriptions-item label="订单审核人">{{form.checker}}</el-descriptions-item>
                         <el-descriptions-item label="阅证人">{{form.name}}</el-descriptions-item>
                       </el-descriptions>
                       <el-table :data="form.items" border :headerCellStyle="{'backgroundColor':'#fff','fontSize':'16px','fontWeight':'bold'}" :cell-style="{'fontSize':'16px','fontWeight':'bold','border-bottom':'1px soild #000'}">
                         <el-table-column label="序号" type="index" width="60" align="center"/>
                         <el-table-column label="财物编号" prop="pno" width="260" align="center"/>
                         <el-table-column label="财物名称" prop="name"width="220" align="center"/>
                         <el-table-column label="数量" prop="nums" width="75" align="center"/>
                         <el-table-column label="特征" prop="character" header-align="center"/>
                         <el-table-column label="保管仓库" prop="storeName" align="center"/>
                         <el-table-column label="库位" prop="locatorName" header-align="center"/>
                       </el-table>
                       <el-row class="mt20">
                         <el-col :span="8" style="padding: 10px 15px;">
                           <div class="mb5">
                             <span>保管员签字</span>
                           </div>
                             <span>
                               <el-image v-if="form.centerSign" class="imgSize" :src="getPictureHost()+form.centerSign" :preview-src-list="[getPictureHost()+form.centerSign]" />
                               <el-image v-else class="imgSize" :src="require('@/assets/images/default-img.png')" />
                               <span>{{'签字时间：'+(form.centerTime && form.centerSign?form.centerTime:'')}}</span>
                             </span>
                         </el-col>
                         <el-col :span="8" style="padding: 10px 15px;">
                           <div class="mb5">
                             <span>阅证人签字</span>
                           </div>
                             <span>
                               <el-image v-if="form.signs" class="imgSize" :src="getPictureHost()+form.signs" :preview-src-list="[getPictureHost()+form.signs]" />
                               <el-image v-else class="imgSize" :src="require('@/assets/images/default-img.png')" />
                               <span>{{'签字时间：'+(form.signsTime && form.signs?form.signsTime:'')}}</span>
                             </span>
                         </el-col>
                       </el-row>
                     </el-card>
                   </div>
                </el-card>
              </el-tab-pane>
              <el-tab-pane label="看样视频" name="3">
                <el-card class="box-card" shadow="hover">
                  <div slot="header" class="clearfix">
                    <el-button style="float: right;" type="default" size="mini" v-if="activate" @click="cancelUploadVideo(form)">取消上传</el-button>
                    <el-button style="float: right;margin-right: 10px;" size="mini" type="primary" v-if="activate" @click="saveTaskVideo(form)">保存</el-button>
                    <el-button style="float: right;" type="default" size="mini" v-if="!activate" @click="openUploadVideo()">上传视频</el-button>
                  </div>
                  <video-upload v-model="form.videoList" ref="videoUpload" :limit="5" :activate="activate"/>
                </el-card>
              </el-tab-pane>
            </el-tabs>


          </el-main>
          <!-- <el-footer class="footerDivClass">
            <el-button type="primary" @click="handleUpdate(form)">阅 证</el-button>
          </el-footer> -->
        </el-container>
      </div>
    </el-drawer>
    <el-drawer  title="看样审核"  :visible.sync="checkShow" size="75%" :before-close="handleCheckClose">
      <div class="mainDiv">
        <el-container class="main_container">
          <el-main style="padding-top: 60px;">
            <el-card class="box-card">
                <div slot="header" class="clearfix">
                  <span>仓库信息</span>
                </div>
                <el-descriptions class="margin-top" :column="2" border>
                    <el-descriptions-item label="仓库">{{store.name}}</el-descriptions-item>
                    <el-descriptions-item label="联系人">{{store.nickName}}</el-descriptions-item>
                    <el-descriptions-item label="联系电话">{{store.phonenumber}}</el-descriptions-item>
                    <el-descriptions-item label="中心电话">{{store.tel}}</el-descriptions-item>
                  </el-descriptions>
             </el-card>
             <el-card class="box-card mt10">
               <div slot="header" class="clearfix">
                 <span>基本信息</span>
               </div>
                <el-descriptions class="margin-top" :column="2" border>
                    <el-descriptions-item label="看样编号">{{form.viewingNo}}</el-descriptions-item>
                    <el-descriptions-item label="仓库">{{form.storeName}}</el-descriptions-item>
                    <el-descriptions-item label="联系人">{{form.name}}</el-descriptions-item>
                    <el-descriptions-item label="联系电话">{{form.tel}}</el-descriptions-item>
                    <el-descriptions-item label="证件类型">{{form.cardType=='0'?'身份证':'警官证'}}</el-descriptions-item>
                    <el-descriptions-item label="证件号码">{{form.idCard}}</el-descriptions-item>
                    <el-descriptions-item label="申请时间">
                      {{ parseTime(form.applyDay) }}
                    </el-descriptions-item>
                    <el-descriptions-item label="状态">
                      <dict-tag :options="dict.type.wms_view_status" :value="form.status" />
                    </el-descriptions-item>
                  </el-descriptions>
             </el-card>
             <el-card class="box-card mt10">
               <div slot="header" class="clearfix">
                 <span>附件信息</span>
               </div>
                <el-descriptions class="margin-top" :column="2" border>
                    <el-descriptions-item label="证件照">
                      <el-image v-if="form.oss && form.oss.length > 0" v-for="(pic,pindex) in form.oss"
                        style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                        :preview-src-list="ossTransfer(form.oss,'list')"></el-image>
                    </el-descriptions-item>
                    <el-descriptions-item label="物品附件">
                      <el-image v-if="form.itemsOss && form.itemsOss.length > 0" v-for="(pic,pindex) in form.itemsOss"
                        style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                        :preview-src-list="ossTransfer(form.itemsOss,'list')"></el-image>
                    </el-descriptions-item>
                    <el-descriptions-item label="中心受理人签名">
                      <el-image style="width: 120px; height: 60px;margin-right: 5px;" :src="getPictureHost()+form.centerSign"/>
                    </el-descriptions-item>
                   <el-descriptions-item label="阅证人签名">
                     <el-image style="width: 120px; height: 60px;margin-right: 5px;" :src="getPictureHost()+form.signs"/>
                   </el-descriptions-item>
                  </el-descriptions>
             </el-card>
             <el-card class="box-card mt10">
               <div slot="header" class="clearfix">
                 <span>物品清单</span>
               </div>
               <el-table :data="form.items" border stripe>
                 <el-table-column type="index" width="55" align="center"></el-table-column>
                 <el-table-column label="物品编号" align="left" prop="pno" width="260">
                   <template slot-scope="scope">
                     <span>{{scope.row.pno}}</span>
                   </template>
                 </el-table-column>
                 <el-table-column label="物品名称" align="left" prop="name" width="200">
                   <template slot-scope="scope">
                     <span>{{scope.row.name}}</span>
                   </template>
                 </el-table-column>
                 <el-table-column label="数量" align="center" prop="nums" width="75">
                   <template slot-scope="scope">
                     <span>{{scope.row.nums}}</span>
                   </template>
                 </el-table-column>
                 <el-table-column label="图片" align="left" prop="oss">
                   <template slot-scope="scope">
                     <el-image v-if="scope.row.oss && scope.row.oss.length > 0" v-for="(pic,pindex) in scope.row.oss"
                       style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                       :preview-src-list="ossTransfer(scope.row.oss,'list')"></el-image>
                   </template>
                 </el-table-column>
               </el-table>
             </el-card>
          </el-main>
          <el-footer>
            <div class="fl">
              <el-radio-group v-model="form.checkStatus">
                  <el-radio :label="1">审核通过</el-radio>
                  <el-radio :label="2">审核不通过</el-radio>
              </el-radio-group>
            </div>
            <div class="fl ml10">
              <el-input v-if="form.checkStatus == '2'" v-model="form.memo" placeholder="请输入不通过理由"></el-input>
            </div>
            <div>
              <el-button type="primary" :loading="buttonLoading" @click="submitCheck" size="mini">确 定</el-button>
              <el-button @click="handleCheckClose" size="mini">取 消</el-button>
            </div>
          </el-footer>
        </el-container>
        </div>
    </el-drawer>
  </div>
</template>

<script>
  import {
    listViewing,
    getViewing,
    delViewing,
    addViewing,
    updateViewing,
    chekcViewing
  } from "@/api/wms/viewing";
  import {
    treeselect
  } from "@/api/system/dept";
  import {
    contacts
  } from "@/api/oms/contacts";
  import {listUser} from "@/api/system/user"
  import {storeTreeselect,getStore} from '@/api/wms/store';
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  import selectProperty from "@/components/SelectProperty/index.vue";
  import {htmlToPdf,htmlToPdfInfo} from "@/utils/pdf.js";
  import {saveVideo} from "@/api/oms/task";
  export default {
    name: "Viewing",
    dicts: ['wms_view_status', 'sys_del_flag','sys_check_status'],
    components:{Treeselect,selectProperty},
    data() {
      return {
        // 按钮loading
        buttonLoading: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 看样记录表格数据
        viewingList: [],
        deptOptions:[],
        storeOptions:[],
        contactsOptions:[],
        defaultProps: {
          children: "children",
          label: "label"
        },
        activeName:0,
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        checkShow:false,
        drawerOpen:false,
        // 图片附件时间范围
        daterangeApplyDay: [],
        // 图片附件时间范围
        daterangeCreateTime: [],
        // 图片附件时间范围
        daterangeUpdateTime: [],
        daterangeFinishTime:[],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          viewingNo: undefined,
          deptId: undefined,
          operator: undefined,
          applyDay: undefined,
          storeId: undefined,
          status: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          delFlag: undefined,
          type:undefined
        },
        storeName:undefined,
        // 表单参数
        form: {},
        store:{},
        // 表单校验
        rules: {
          // viewingNo: [{
          //   required: true,
          //   message: "看样编号不能为空",
          //   trigger: "blur"
          // }],
          deptId: [{
            required: true,
            message: "申请部门ID不能为空",
            trigger: "blur"
          }],
          operator: [{
            required: true,
            message: "申请人不能为空",
            trigger: "blur"
          }],
          applyDay: [{
            required: true,
            message: "申请日期不能为空",
            trigger: "blur"
          }],
          storeId: [{
            required: true,
            message: "仓库ID不能为空",
            trigger: "blur"
          }],
        },
        activate:false
      };
    },
    watch:{
      'form.deptId': {
        handler(newVal, oldVal) {
          this.selectDeptId()
        }
      }
    },
    created() {
      this.getList();
      this.getTreeselect();
      this.getStoreTreeselect();
    },
    methods: {
      /** 查询看样记录列表 */
      getList() {
        this.loading = true;
        this.queryParams.params = {};
        if (null != this.daterangeApplyDay && '' != this.daterangeApplyDay) {
          this.queryParams.params["beginApplyDay"] = this.daterangeApplyDay[0];
          this.queryParams.params["endApplyDay"] = this.daterangeApplyDay[1];
        }
        if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
          this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
          this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
        }
        if (null != this.daterangeUpdateTime && '' != this.daterangeUpdateTime) {
          this.queryParams.params["beginUpdateTime"] = this.daterangeUpdateTime[0];
          this.queryParams.params["endUpdateTime"] = this.daterangeUpdateTime[1];
        }
        listViewing(this.queryParams).then(response => {
          this.viewingList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 查询部门下拉树结构 */
      getTreeselect() {
        treeselect().then(response => {
          this.deptOptions = response.data;
        });
      },
      /** 查询分类下拉树结构 */
      getStoreTreeselect() {
        storeTreeselect().then(response => {
          this.storeOptions = response.data;
        });
      },
      getStoreInfo(id){
         getStore(id).then(response=>{
           this.store = response.data;
         })
      },
      selectDeptId(){
        this.getContacts();
      },
      getContacts(){
        // contacts({'deptId':this.form.deptId}).then(response => {
        //   this.contactsOptions = response.data
        // })
        listUser({'deptId':this.form.deptId}).then(response=>{
          this.contactsOptions = response.rows;
        })
      },
      openUploadVideo(){
        this.activate = true;
      },
      cancelUploadVideo(item){
        let form = {id:item.id,videoList:[]}
        saveVideo(form).then((res) => {
          this.form.videoList = res.data.videoList;
          this.activate =false;
        }).finally(() => {
        })
      },
      saveTaskVideo(item){
        this.loading = true;
        saveVideo(item).then((res) => {
          console.info(res);
          this.$modal.msgSuccess("保存成功");
          this.form.videoList = res.data.videoList;
          this.activate =false;
        }).finally(() => {
          this.loading = false;
        })
      },
      // 筛选节点
      filterNode(value, data) {
        if (!value) return true;
        return data.label.indexOf(value) !== -1;
      },
      // 节点单击事件
      handleNodeClick(data) {
        this.queryParams.storeId = data.id;
        this.handleQuery();
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          viewingNo: undefined,
          deptId: undefined,
          operator: undefined,
          applyDay: undefined,
          storeId: undefined,
          status: "0",
          memo: undefined,
          pics: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          delFlag: undefined,
          personData:[],
          items:[]
        };
        this.resetForm("form");
      },
      addDtl(){
        this.$refs.elDrawer.open()
      },
      dtlDel(scope){
        let index = scope.$index;
        if(this.form.items[index].id && this.form.items[index].id != ''){
          this.form.items[index].delFlag='2';
        }else{
          this.form.items.splice(index,1)
        }

      },
      //获取选择后的财务数据
        handleSelected(array){
          array.forEach(item=>{
            item.delFlag = '0'
            item.id=undefined
            this.form.items.push(item)
          })
        },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.daterangeApplyDay = [];
        this.daterangeCreateTime = [];
        this.daterangeUpdateTime = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加看样记录";
        this.form.storeId = this.queryParams.storeId
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.loading = true;
        this.reset();
        const id = row.id || this.ids
        this.$modal.confirm('是否确认已阅？').then(() => {
          this.loading = true;
          row.status = '1'
          return updateViewing(row);
        }).then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("操作成功");
        }).finally(() => {
          this.loading = false;
        });
      },
      handleInfo(row){
        const id = row.id || this.ids
        getViewing(id).then(response => {
          this.form = response.data;
          let newName = '';
          response.data.personData.map((item,index) => {
            const personType = item.cardType==='0'?'(身份证:':'(警官证:'
            if(index ===0){
              newName = item.name + personType + item.idCard+')'
            }else{
              newName = item.name + personType + item.idCard+')' + ' ,' + newName
            }
          })
          this.form.name = newName
          this.drawerOpen = true;
          this.title = "看样详情";
          if(response.data.storeId){
            this.getStoreInfo(response.data.storeId);
          }
        });
      },
      handleCheck(row){
        this.checkShow = true;
        getViewing(row.id).then(response=>{
          this.form = response.data;
          let newName = '';
          for(let i = 0; i < this.form.personData; i++) {
            if(i === 0){
              newName = this.form.personData[i].name + '(' + this.form.personData[i].cardType=='0'?'身份证:':'警官证:'+ this.form.personData[i].idCard+')'
            }else{
              newName = this.form.personData[i].name + '(' + this.form.personData[i].cardType=='0'?'身份证:':'警官证:'+ this.form.personData[i].idCard+')' + ' ,' + newName
            }
          }
          this.form.name = newName
          this.checkShow = true;
        })
      },
      handleCheckClose(){
        this.checkShow = false;
        this.activate = false;
        this.buttonLoading = false;
      },
      //审核
      submitCheck(){
        let content = '是否确认审核通过';
        if(this.form.checkStatus == 2){
          content = '是否确认审核不通过'
        }
        this.buttonLoading = true;
        this.$modal.confirm(content).then(() => {
          this.loading = true;
          return chekcViewing(this.form);
        }).then(() => {
          this.loading = false;
          this.buttonLoading = false;
          this.handleCheckClose();
          this.resetQuery();
          this.$modal.msgSuccess("审核完成");
        }).finally(() => {
          this.loading = false;
          this.buttonLoading = false;
        });
      },
      close(){
        this.open = false;
        this.drawerOpen = false;
        this.activate = false;
      },
      handleClose(){
        this.drawerOpen = false;
        this.activate = false;
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          this.form.oss = this.$refs["imageUpload"].pics;
          if (valid) {
            this.buttonLoading = true;
            if (this.form.id != null) {
              updateViewing(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }).finally(() => {
                this.buttonLoading = false;
              });
            } else {
              addViewing(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }).finally(() => {
                this.buttonLoading = false;
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('是否确认删除看样记录编号为"' + ids + '"的数据项？').then(() => {
          this.loading = true;
          return delViewing(ids);
        }).then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).finally(() => {
          this.loading = false;
        });
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('wms/viewing/export', {
          ...this.queryParams
        }, `viewing_${new Date().getTime()}.xlsx`)
      },
      /**
       * 附件打印
       */
      handlePrint(title){
        htmlToPdf('#printHandover',title)
      },
      handlePrintInfo(){
        htmlToPdfInfo("#printHandover");
      },
    }
  };
</script>
<style>
  .imgSize{
    width: 100%;
    height: 150px;
  }
</style>
